package nav.luch.com.navtest;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.mt.sdk.view.BTWebView;


public class MainActivity extends AppCompatActivity {

    private BTWebView btweb;
    //导航初始化地址，在自己的场景中查看appid。后台管理地址：http://i.vr100.com/intest/adminbuilding.php
 public  final String URL_NAV = "http://i.vr100.com/intest/showuiappio"
            + ".html?appid=m8wnnrhXaExzAWpp";
// public  final String URL_NAV = "http://i.vr100.com/intest/showuiappio"
  //          + ".html?appid=m8wnnrhXaExzAWpp";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();//初始化场景
        btweb.startScan();//开始扫描
    }
    private void initView(){
      btweb = (BTWebView) findViewById(R.id.btweb);
        btweb.InitUrl(URL_NAV);
        btweb.addGetJsParamListener(new BTWebView.SetParamAppListener() {
            @Override
            public void setParamApp(String paraName, String paraValue) {
                 //   Toast.makeText(MainActivity.this, "from server:   K1 " + paraName + "  v:" + paraValue, Toast.LENGTH_LONG).show();
                if (paraName.equals("isMapLoad")){//地图记载完成后的一些地图配置
                  //  Log.e("key-->" + paraName , "value-->" + paraValue);
                    runOnUiThread(new Runnable(  ) { //一些初始配置一定要放在此函数内，否则不成功
                        @Override
                        public void run() {
                            btweb.getParamApp("setInitPos","17 0 0");//设置我的定位的初始位置
                            btweb.getParamApp("naviByPos","{'x':'80','y':'50','z':'4'}");//根据位置导航,建议放某个按钮那里，或者使用时钟，等待秒钟加载。
                        }
                    });

                }

            }
        });
        Toast.makeText(this,"正在初始化场景,请稍等..",Toast.LENGTH_SHORT).show();
    }

}
